package com.quarantine.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springside.modules.orm.Page;

import com.quarantine.dao.newsphotoDao;
import com.quarantine.model.newsphoto;

@Component
@Transactional
public class NewsphotoManager {

	private newsphotoDao newsphotoDao;
	
	public newsphotoDao getNewsphotoDao() {
		return newsphotoDao;
	}
	@Autowired
	public void setNewsphotoDao(newsphotoDao newsphotoDao) {
		this.newsphotoDao = newsphotoDao;
	}

	
	@Transactional
    public void set(newsphoto entity){
    	System.out.println(entity.getPicturepath());
    	
    	newsphotoDao.save(entity);
  
    }
	 /***
     * 显示后台图片新闻列表
     * @param page
     * @return
     */
    @Transactional 
    public Page<newsphoto> getList(final Page<newsphoto>page ) {
	return newsphotoDao.findPage(page, "from newsphoto order by edit_time desc");
}
    /***
     * 显示前台图片新闻列表
     * @param page
     * @return
     */
    @Transactional 
    public Page<newsphoto> getList1(final Page<newsphoto>page ) {
	return newsphotoDao.findPage(page, "from newsphoto order by input_time desc");
}
	@Transactional      
    /**
     * 根据id来删除
     */
    public void delete(String id){
    	newsphotoDao.delete(id);
    }
    
    @Transactional      
    /**
     * 根据id查找
     */
	public newsphoto getById(String id) {
		return newsphotoDao.findUniqueBy("id", id);
	}
}
